/**
 * Created: 2011-7-23
 * By:		eeorange
 * About:	pku 1753 - Flip Game
 * Status:	168K 63MS 
 * Details:	bfs 464K 16MS 
 */

#include <cstdio>
#include <cstring>

#define MAXN	(65535+10)
typedef unsigned int State;
const unsigned int mask = 0xffff;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const State peri[16] = {0x13, 0x27, 0x4e, 0x8c, 0x131, 0x272, 0x4e4, 0x8c8, 0x1310, 0x2720, 0x4e40, 0x8c80, 0x3100, 0x7200, 0xe400, 0xc800};
State st[MAXN];
int vis[MAXN], deep[MAXN];

void read_input(){
	State& src = st[0];
	char ch[5];
	for(int i=0; i<4; i++)
	{
		scanf("%s", ch);
		for(int j=0; j<4; j++)
			src |= (ch[j] == 'b') ? (1 << i*4+j) : 0;
	}
}

/* return -1 if fail	*/
int bfs(){
	deep[0] = 0;
	int front = 0, rear = 1;
	while(front < rear)
	{
		State& s = st[front];
		if((s&mask) == 0 || (s&mask) == 0xffff) return deep[front]; 
		for(int i=0; i<16; i++)
		{
			State& t = st[rear];
			memcpy(&t, &s, sizeof(State));
			t ^= peri[i];
			deep[rear] = deep[front]+1;
			if(!vis[t]){ vis[t] = 1; rear++;}		// push queue
		}
		front++;		// pop queue
	}
	return -1;
}


int main(){
	read_input();
	memset(vis, 0, sizeof(vis));
	int ret = bfs();
	if(ret != -1)
		printf("%d\n", ret);
	else 
		printf("Impossible\n");
	
	
	return 0;
}

